package com.more.offer.designpatterns.singleton.lazyinitialization;

/**
 * @author pinoc
 * @date 2021/10/22
 * @description 推荐最后一种bill push方式创建单例
 */
public class SingleTest {

	public static void main(String[] args) {
		new Thread(() -> {
			System.out.println(LazySingleton.getInstance());
		}).start();
		new Thread(() -> {
			System.out.println(LazySingleton.getInstance());
		}).start();
		System.out.println("---");

		new Thread(() -> {
			System.out.println(ThreadSafeLazySingleton.getInstance());
		}).start();
		new Thread(() -> {
			System.out.println(ThreadSafeLazySingleton.getInstance());
		}).start();
		System.out.println("---");


		new Thread(() -> {
			System.out.println(ThreadSafeSingletonWithBillPush.getInstance());
		}).start();
		new Thread(() -> {
			System.out.println(ThreadSafeSingletonWithBillPush.getInstance());
		}).start();
	}
}
